<?
require_once("../config/dbconn.php");require_once("../config/powercls.php");


//奖金发放

//开始发放奖金
$sql="select * from {$db_prefix}salary1 where id='$id'";
$rs=$db->get_one($sql);
$periods=$rs['periods'];$beginday=$rs['beginday'];

$MSG='';
if ($rs['isff']==0){
		$hyflprice=$rs['flprice'];
		$hyjjall=$rs['flprice']-$rs['fax'];
		//发放奖金
		$sqljj="update {$db_prefix}users set jjprice=jjprice+'$hyjjall',priceall=priceall+'$hyflprice' where id='".$rs['userid']."'";
		$db->query($sqljj);
		$sqlgx="update {$db_prefix}salary1 set isff=1,fftime='$curtime' where id='".$rs['id']."'";
		$db->query($sqlgx);
		//财务记录
		$e_userid=$rs['userid'];$e_price=$hyjjall;$e_type=15;$e_ptype=3;$e_addtime=$curtime;$e_memo="{$beginday}日返利";
		hyepricejl($e_userid,$e_price,$e_type,$e_ptype,$e_addtime,$e_memo);
		$MSG='奖金已经发放';
}else{
	$MSG='奖金已发放、不需要重复发放';
}

echo "{$MSG}<bR>";

echo "<a href='salary_rec.php?periods={$periods}&pageno={$pageno}' style='color:red'>返回奖金列表</a>";
exit();
?>